package net.cyue.easyconfiguration.toml.test;

import net.cyue.easyconfiguration.ConfigurationDefinition;
import net.cyue.easyconfiguration.ConfigurationLoader;
import net.cyue.easyconfiguration.toml.TOMLConfigurationResource;
import net.cyue.easyconfiguration.toml.test.data.ConfigItemValue;
import net.cyue.easyconfiguration.toml.test.data.Configuration;
import net.cyue.easyconfiguration.node.NodeType;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

public class TestTOMLConfiguration {

    @Test
    public void test() throws IOException, NoSuchMethodException, InvocationTargetException, NoSuchFieldException {
        ConfigurationDefinition definition = ConfigurationDefinition.builder()
            .addConfigItem(
                NodeType.STRING,
                "handler",
                "application.context.handler.*"
            )
            .addConfigItem(
                "api",
                ConfigItemValue.API.class,
                "api.*"
            )
            .build();
        Configuration configuration = ConfigurationLoader.load(
            Configuration.class,
            definition,
            TOMLConfigurationResource.fromResource("example.toml")
        );
        System.out.println(configuration);
    }
}
